/**
 * 配置参考: https://cli.vuejs.org/zh/config/
 */
const FileManagerPlugin = require('filemanager-webpack-plugin')
const CompressionWebpackPlugin = require('compression-webpack-plugin')
module.exports = {
  publicPath: process.env.NODE_ENV === 'production' ? '/board/' : '/',
  chainWebpack: config => {
    const svgRule = config.module.rule('svg')
    svgRule.uses.clear()
    svgRule
      .test(/\.svg$/)
      .use('svg-sprite-loader')
      .loader('svg-sprite-loader')
  },
  // 默认打开eslint效验，如果需要关闭，设置成false即可
  lintOnSave: false,
  productionSourceMap: false,
  devServer: {
    open: true,
    port: 8001,
    overlay: {
      errors: true,
      warnings: true
    }
  },
  configureWebpack: {
    externals: {
      AMap: 'AMap'
    },
    plugins: [
      new CompressionWebpackPlugin(),
      new FileManagerPlugin({ // 初始化 filemanager-webpack-plugin 插件实例
        events: {
          onEnd: {
            delete: [ // 首先需要删除项目根目录下的dist.zip
              './dist.zip'
            ],
            archive: [ // 然后我们选择dist文件夹将之打包成dist.zip并放在根目录
              { source: './dist', destination: './dist.zip' }
            ]
          }
        }
      })
    ]
  }
}
